CFLAGS = -g -O2 -Wall 
LDFLAGS = 
LIBS = 
EXPAT_LIBS =  -lexpat
ERLANG_LIBS = -L/usr/local/lib/erlang/lib/erl_interface-3.6.4/lib -lerl_interface -lei
EXPAT_CFLAGS = 
ERLANG_CFLAGS= -I/usr/local/lib/erlang/lib/erl_interface-3.6.4/include -I/usr/local/lib/erlang/usr/include
DYNAMIC_LIB_CFLAGS = -fpic -shared

all: expat_erl.so xml.beam xml_stream.beam test.beam

clean:
	rm -rfv *.beam
	rm -rfv *.so
	rm -rfv *~

xml.beam: xml.erl
	erlc -o $@ $<

xml_stream.beam: xml_stream.erl
	erlc -o $@ $<

test.beam: test.erl
	erlc -o $@ $<

expat_erl.so:	%.so:	%.c
	gcc $(CFLAGS) $(LDFLAGS) $(LIBS) \
		$(subst ../,,$(subst .so,.c,$@)) \
		$(EXPAT_LIBS) \
		$(EXPAT_CFLAGS) \
		$(ERLANG_LIBS) \
		$(ERLANG_CFLAGS) \
		-o $@ \
		$(DYNAMIC_LIB_CFLAGS)
